// pages/inquire/inquire.js
var app = getApp();

Page({

  /**
   * 页面的初始数据
   */
  data: {
    baseInfo: null,
    name: '',//姓名
    idCard: '',//身份证号
    iphone: '',//手机号
    name2: '',//配偶姓名
    idCard2: '',//配偶身份证号
    iphone2: '',//配偶手机号
    score: 0,//初审总分数

  },

  // 获取填写的姓名
  NAME: function (e) {
    console.log(e.detail.value)
    this.setData({
      name: e.detail.value
    })

  },
  // 获取填写身份证号
  IDCARD: function (e) {
    console.log(e.detail.value)
    this.setData({
      idCard: e.detail.value
    })
  },
  // 获取填写手机号
  IPHONE: function (e) {
    console.log(e.detail.value)
    this.setData({
      iphone: e.detail.value
    })
  },
  // 获取填写的配偶姓名
  NAME2: function (e) {
    console.log(e.detail.value)
    this.setData({
      name2: e.detail.value
    })

  },
  // 获取填写配偶身份证号
  IDCARD2: function (e) {
    console.log(e.detail.value)
    this.setData({
      idCard2: e.detail.value
    })
  },
  // 获取填写配偶手机号
  IPHONE2: function (e) {
    console.log(e.detail.value)
    this.setData({
      iphone2: e.detail.value
    })
  },
  // 获取填写银行卡号
  // MONEY: function (e) {
  //   console.log(e.detail.value)
  //   this.setData({
  //     money: e.detail.value
  //   })
  // },


  // 提交保存数据的事件
  submit: function () {
    var that = this;

    wx.request({
      url: app.globalData.serviceUrl + '/chuShen/search',
      data: {
        baseInfoId: that.data.baseInfo.id,
        orderNum: that.data.baseInfo.orderId
      },
      method: "GET",
      success(res) {
        if(res.data.success) {
          that.setData({
            score: res.data.data
          });
        }
      }
    })
  },

  // 提交保存数据的事件2

  submit2: function () {


    var that = this;
    if (that.data.name == '') {
      wx.showModal({
        title: '提示',
        content: '车友姓名不能为空',
        confirmText: "确定",
        showCancel: false,
      })
    }
    else if (that.data.idCard == '') {
      wx.showModal({
        title: '提示',
        content: '车友身份证号不能为空',
        confirmText: "确定",
        showCancel: false,
      })
    }
    else if (that.data.idCard.length !== 18) {
      wx.showModal({
        title: '提示',
        content: '车友身份证号格式不对',
        confirmText: "确定",
        showCancel: false,
      })
    }
    else if (that.data.iphone == '') {
      wx.showModal({
        title: '提示',
        content: '车友手机号不能为空',
        confirmText: "确定",
        showCancel: false,
      })
    }
    else if (that.data.iphone.length !== 11) {
      wx.showModal({
        title: '提示',
        content: '车友手机号格式不对',
        confirmText: "确定",
        showCancel: false,
      })
    } else if (that.data.name2 == '') {
      wx.showModal({
        title: '提示',
        content: '配偶姓名不能为空',
        confirmText: "确定",
        showCancel: false,
      })
    }
    else if (that.data.idCard2 == '') {
      wx.showModal({
        title: '提示',
        content: '配偶身份证号不能为空',
        confirmText: "确定",
        showCancel: false,
      })
    }
    else if (that.data.idCard2.length !== 18) {
      wx.showModal({
        title: '提示',
        content: '配偶身份证号格式不对',
        confirmText: "确定",
        showCancel: false,
      })
    }
    else if (that.data.iphone2 == '') {
      wx.showModal({
        title: '提示',
        content: '配偶手机号不能为空',
        confirmText: "确定",
        showCancel: false,
      })
    }
    else if (that.data.iphone2.length !== 11) {
      wx.showModal({
        title: '提示',
        content: '配偶手机号格式不对',
        confirmText: "确定",
        showCancel: false,
      })
    } else {


    }
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    
    wx.request({
      url: app.globalData.serviceUrl + '/wcBasicInfo/getBaseInfoByOrderId',
      data: {
        orderId: options.orderId
      },
      method: "GET",
      success(res) {
        if(res.data.success) {
          that.setData({
            baseInfo: res.data.data
          });
          
          wx.request({
            url: app.globalData.serviceUrl + '/chuShen/queryByOrderNum',
            data: {
              orderNum: options.orderId
            },
            method: "GET",
            success(res) {
              if(res.data.success) {
                that.setData({
                  score: res.data.data.score
                });
              }
            }
          })
          
        }
      }
    })

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})